package com.hqj.client.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.hqj.client.entity.UserRole;
import com.hqj.client.mapper.UserRoleMapper;
import com.hqj.client.service.UserRoleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 黄啟军
 * @version 1.0
 * @date 2020/5/16/016
 */
@Service
public class UserRoleServiceImpl implements UserRoleService {

    @Resource
    private UserRoleMapper userRoleMapper;
    /**
     * UserRole分页查询
     * @param page
     * @param size
     * @return
     */
    @Override
    public List<UserRole> findPage(int page, int size){
        //QueryWrapper<UserRole> wrapper = new QueryWrapper<>();
        IPage<UserRole> findpage = userRoleMapper.selectPage(new Page<>(page, size),null);
        return findpage.getRecords();
    }
    /**
     * 删除
     * @param id
     */
    @Override
    public int delete(Long id){
        UserRole userRole = userRoleMapper.selectById(id);
       // userRole.setIsDelete(1);
        return userRoleMapper.updateById(userRole);
    }
    /**
     * 修改UserRole
     * @param userRole
     */
    @Override
    public int  update(UserRole userRole){

        return userRoleMapper.updateById(userRole);
    }
    /**
     * 增加UserRole
     * @param userRole
     */
    @Override
    public int add(UserRole userRole){
        return userRoleMapper.insert(userRole);
    }
    /**
     * 根据ID查询UserRole
     * @param id
     * @return
     */
    @Override
    public UserRole findById(Long id){
        return  userRoleMapper.selectById(id);
    }
    /**
     * 查询UserRole全部数据
     * @return
     */
    @Override
    public List<UserRole> findAll() {
        return userRoleMapper.selectList(null);
    }
}
